package com.chinaunicom.emergency.model;


import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;


/**
 * @author liliang
 * @date 2019-12-13
 */
@Entity
@Getter
@Setter
@EqualsAndHashCode
@Table(name = "yjgl_user")
public class YjglUser implements Serializable {

    @Id
    @GeneratedValue(generator="yjglUserUUID")
    @GenericGenerator(name="yjglUserUUID",strategy="uuid")
    private String pid;

    @ApiModelProperty(value="单位id")
    private String departmentId;

    @ApiModelProperty(value="用户名账号")
    private String userName;

    @ApiModelProperty(value="姓名")
    private String realName;

    @ApiModelProperty(value="密码")
    private String password;

    @ApiModelProperty(value="最后登录时间")
    private Date lastLogintime;

    @ApiModelProperty(value="是否可用,1可用,0不可用")
    private Integer enabled;

    @ApiModelProperty(value="账户是否不过期,1是,0否")
    private Integer accountIsNotExpired;

    @ApiModelProperty(value="账户是否不被锁定,1是0否")
    private Integer accountIsNotLocked;

    @ApiModelProperty(value="凭据是否不过期,1是,0否")
    private Integer credentialIsNotExpired;

    @ApiModelProperty(value="排序")
    private Integer orderNum;

    @ApiModelProperty(value="用户所属机构id")
    private String orgId;

    public List<String> getOrgIdList(){
        return Arrays.asList(orgId.split(","));
    }

    @ApiModelProperty(value="年龄")
    private Integer age;

    @ApiModelProperty(value="性别,1男0女")
    private Integer sex;

    @ApiModelProperty(value="原密码")
    private String oldPassword;

    @ApiModelProperty(value="创建人")
    private String createBy;

    @ApiModelProperty(value="创建时间")
    private Date createTime;

    @ApiModelProperty(value="修改人")
    private String updateBy;

    @ApiModelProperty(value="修改时间")
    private Date updateTime;

    @ApiModelProperty(value="软删除,1删除,0未删除")
    private Integer isSoftDel;

    @ApiModelProperty(value="删除人")
    private String deleteBy;

    @ApiModelProperty(value="删除时间")
    private Date deleteTime;

    @ApiModelProperty(value="token")
    private String accessToken;

    @Transient
    private String orgNameStr;

    @Override
    public String toString(){
        return JSONObject.toJSONString(this);
    }

}
